--modimport('mymain/')
AddModRPCHandler("mymod", "cs", function(inst)
    if not GLOBAL.TheWorld.ismastersim or (not inst or not inst:IsValid() or inst:HasTag("playerghost")) then
        print("RPC检查失败") -- 添加调试信息
        return
    end
    --------------------------------------------------------------------------------
    -- print("开始生成特效")
    -- local x, y, z = inst.Transform:GetWorldPosition()
    -- local mytexiao = SpawnPrefab("mytexiao")
    -- mytexiao.Transform:SetPosition(x, y, z)
    --------------------------------------------------------------------------------
    --标签测试--
    -- -- 下面是 dm_counttags 中核心逻辑的移植，简化后用于输出当前玩家的标签数量
    -- local player = inst
    -- if player and player.entity then
    --     local str = player.entity:GetDebugString()
    --     local tags_str = str:match("Tags: (.+)\nPrefab:")
    --     if tags_str == nil then
    --         print("该实体没有标签")
    --         return
    --     end
    --     local tags = string.split(tags_str, " ")
    --     local count = #tags
    --     print(string.format("玩家 %s 当前拥有 %d 个标签:", player.prefab, count))

    --     local line = ""
    --     for i, tag in ipairs(tags) do
    --         line = line .. tag .. "|"
    --         if i % 10 == 0 then
    --             print(line)
    --             line = ""
    --         end
    --     end
    --     if line ~= "" then
    --         print(line)
    --     end
    -- end
    --------------------------------------------------------------------------------
    
-- local map = {
--     clocktick = true,
--     locomote = true,
--     sanitydelta = true,
--     moisturedelta = true,
--     temperaturedelta = true,
--     weathertick = true,
--     overridecolourmodifier = true,
--     pre_health_setval = true,
--     healthdelta = true,
--     entitysleep = true,
--     entity_spawned = true,
--     entitywake = true,
--     nightmareclocktick = true,
--     temperaturetick = true,
--     actioncomponentsdirty= true,
--     on_landed = true,
--     nightmarephasechanged = true,
--     animover = true,
--     timerdone = true,
--     sanitydirty = true,
--     lightdirty = true,
--     hungerdelta = true,
--     onreachdestination = true,
--     newstate = true,
--     animqueueover = true,
--     pulsetimedirty = true,
--     master_clockupdate = true,
--     onremove = true,
--     healthdirty = true,
--     perishdirty = true,
--     forceperishchange = true,
--     isperformactionsuccessdirty = true,
--     performaction = true,
--     temperaturedirty = true,
--     mouseover = true,
--     mouseout = true,
--     clientsideinventoryflagschanged = true,
--     invincibletoggle = true,
--     windchange = true,
--     colourtweener_end = true,
--     skilltreeinitialized_client = true,
--     ms_skilltreeinitialized = true,
--     onsetskillselection_server = true,
--     colourtweener_start = true,
--     moisturedirty = true,
--     playervotechanged = true,
--     fx_spawned = true,
--     hideworldreset = true,
--     floater_startfloating = true,
--     landeddirty = true,
--     ms_registersoildrinker = true,
--     ms_moonstormwindowover = true,
--     plantherdspawned = true,
--     playerentered = true,
--     playercountsdirty = true,
--     yotd_ratraceprizechange = true,
--     onwordpredictionupdated = true,
--     perishchange = true,
--     donetalking = true,
--     sharksounddirty = true,
--     hungerdirty = true,
--     chatterdirty = true,
--     ontalk = true,
--     techtreechange = true,
--     current_prototyper_dirty = true,
--     itemlose = true,
--     exitlimbo = true,
--     forgetinventoryitem = true,
--     unregister_hudindicatable = true,
--     moonphasestylechanged = true,
--     mounthurt = true,
--     yotbskinupdate = true,
--     item_buff_changed = true,
--     roseglassescooldownchanged = true,
--     inspectaclesgamechanged = true,
--     isacidsizzling = true,
--     miasmalevel = true,
--     stagedirty = true,
--     techtreesdirty = true,
--     ms_spawnedsharkboiarena = true,
--     insight_moisture_rate_dirty = true,
--     imagechange = true,
--     on_no_longer_landed = true,
--     serverpauseddirty = true,
--     refreshhudsize = true,
--     ms_playercounts = true,
-- }
-- local old_PushEvent = EntityScript.PushEvent
-- function EntityScript:PushEvent(eventname, ...)
--     if not map[eventname] then
--         print(eventname)
--     end
--     return old_PushEvent(self, eventname, ...)
-- end
end)
AddPlayerPostInit(function(inst)
    inst:DoTaskInTime(1, function()                       --按键测试
        GLOBAL.TheInput:AddKeyHandler(function(key, down) -- 监听键盘事件
            if down and key == GLOBAL.KEY_R then
                SendModRPCToServer(MOD_RPC["mymod"]["cs"])
            end
        end)
    end)
end)